﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Vit.SchemaExplorer
{
    [Serializable]
    public abstract class TabularObjectBase<T> : SchemaObjectBase where T : ColumnSchemaBase
    {
        public TabularObjectBase()
            : base()
        {
            Columns = new List<T>();
        }

        public T GetColumn(string name)
        {
            return Columns.FirstOrDefault(o => string.Equals(o.Name, name, StringComparison.OrdinalIgnoreCase));
        }

        public string FullName
        {
            get
            {
                return this.Schema.Database.SchemaProvider.BuildFullName(this.Schema.Name, this.Owner, this.Name);
            }
        }
        public List<T> Columns { get; set; }
    }
}
